#!/bin/bash

# 执行命令并遍历其输出的每一行
while IFS= read -r line; do
    nm=$(echo "$line" | awk '{print $1}')
    case "$line" in
        *null*)
            wlr-randr --output $nm --off
            ;;
        HDMI-*)
            wlr-randr --output $nm --pos 0,0
            mpvpaper -o "no-audio loop" $nm ~/Pictures/video/bg02.mp4 > /dev/null 2>&1 &
            ;;
        VGA-*)
            wlr-randr --output $nm --pos 1920,0
            mpvpaper -o "no-audio loop" $nm ~/Pictures/video/bg01.mp4 > /dev/null 2>&1 &
            ;;
    esac
done < <(wlr-randr | grep -E '^(HDMI|VGA|LVDS)' )
